package cn.news.control;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.news.biz.RegisterBiz;
import cn.news.entity.User;

public class UserResServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String name=request.getParameter("c_input1");
		String pass=request.getParameter("c_input2");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out=response.getWriter();
		User user=new User(name,pass);
		RegisterBiz rBiz=new RegisterBiz();
		if(rBiz.addUser(user)){
			out.print("<script>alert('提交成功,3秒后跳转到登陆页面')</script>");
			response.setHeader("refresh", "3;URL=UserSeekServlet");
		}
	}
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
		
	}
}
